home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINFONTS
/
FNTPRN.ZIP
/
FNTSRC.ZIP
/
FNTPRN.C
< prev
next >
Wrap
Text File
|
1993-03-16
|
16KB
|
357 lines
// Contents copyright (c) 1993 John Deurbrouck
/*
** Includes
*/
#include<windows.h>
#include<commdlg.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include"controls.h"
#include"enumfont.h"
/*
** Defines
*/
#define IDD_GETGOING 200
#define IDM_ABOUT 1
#define IDM_HELP 2
/*
** Global Variables
*/
int OldLfHeight;
HCURSOR hHourGlass; // global so call LoadCursor() just once
/*
** Function Prototypes
*/
long FAR PASCAL _export WndProc(HWND,UINT,UINT,LONG);
static void show_default_text_settings(HWND hwndDesc);
/*
** Function Definitions
*/
#pragma argsused
int PASCAL WinMain(HANDLE hInstance,HANDLE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow){
MSG msg;
HWND hwnd;
WNDCLASS wndclass;
static LPSTR appname="FntPrn";
instance=hInstance;
hHourGlass=LoadCursor(NULL,IDC_WAIT);
// verify we're in Win 3.1 or better
{
DWORD dwVersion=GetVersion();
unsigned int winver=((unsigned int)LOBYTE(LOWORD(dwVersion)))<<8;
winver|=(unsigned int)HIBYTE(LOWORD(dwVersion));
if(winver<0x30A){
MessageBox(NULL,"FntPrn requires Windows 3.1 or later",
"ERROR",MB_OK|MB_ICONSTOP);
return 1;
}
}
if(!hPrevInstance){
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=DLGWINDOWEXTRA;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(hInstance,"FntPrn2");
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=COLOR_WINDOW+1;
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=appname;
RegisterClass(&wndclass);
}
hwnd=CreateDialog(hInstance,appname,0,NULL);
if(!hwnd){
MessageBox(NULL,"Could not create window","ERROR",MB_OK|MB_ICONSTOP);
return 1;
}
hwndDialog=hwnd;
// add new options to System Menu
{
HMENU hMenu;
hMenu=GetSystemMenu(hwnd,FALSE);
if(hMenu!=NULL){
EnableMenuItem(hMenu,SC_MAXIMIZE,MF_BYCOMMAND|MF_GRAYED);
EnableMenuItem(hMenu,SC_SIZE,MF_BYCOMMAND|MF_GRAYED);
AppendMenu(hMenu,MF_SEPARATOR,0,NULL);
AppendMenu(hMenu,MF_STRING,IDM_ABOUT,"&About...");
AppendMenu(hMenu,MF_STRING,IDM_HELP,"&Help...");
}
}
// get dialog box initialized
PostMessage(hwnd,WM_COMMAND,IDD_GETGOING,0L);
ShowWindow(hwnd,nCmdShow);
while(GetMessage(&msg,NULL,0,0)){
// next line intercepts ESC key so IsDialogMessage() can't exit on it
if((msg.message==WM_KEYDOWN&&msg.wParam==VK_ESCAPE)||(!IsDialogMessage(hwnd,&msg))){
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
}
return msg.wParam ;
}
// this is a dialog box procedure but is also the main window
long FAR PASCAL _export WndProc(HWND hwnd,UINT message,UINT wParam,LONG lParam){
static HWND hwndSampletext,hwndJustification,hwndSize,hwndDesc;
HCURSOR hSaveCursor;
switch(message){
case WM_KEYDOWN:
if(wParam==VK_ESCAPE)return 1;
break;
case WM_SYSCOMMAND:
switch(wParam){
case IDM_ABOUT:
MessageBox(hwndDialog,
"FntPrn 1.0\n"
"Font Printing Utility\n"
"Copyright ⌐ 1993 John Deurbrouck\n\n"
"First Published in PC Magazine April 13, 1993",
"FontPrint",MB_OK);
SetFocus(hwndSortorder);
return 1;
case IDM_HELP:
MessageBox(hwndDialog,
"FntPrn helps you browse your fonts.\n\n"
"You choose which fonts to see and how to sort them (Fonts section), "
"what you want to see in each font (Sample Text section), "
"and how you want the font names to look (Description Formatting section).\n\n"
"FntPrn creates a file (FNTPRN.WRI by default) "
"and optionally starts Write so you can browse or print the report.\n\n"
"See PC Magazine, April 13, 1993 (Vol. 12 No. 7) for more details.",
"FontPrint Help",MB_OK);
SetFocus(hwndSortorder);
return 1;
}
break;
case WM_COMMAND:
switch(wParam){
case IDD_GETGOING:
// do this instead of WM_INITDIALOG since child windows
// won't have been created by that time
hwndSortorder=GetDlgItem(hwnd,IDD_SORTORDER);
SendMessage(hwndSortorder,CB_INSERTSTRING,0,(LONG)(LPSTR)"Alphabetical");
SendMessage(hwndSortorder,CB_INSERTSTRING,1,(LONG)(LPSTR)"Height");
SendMessage(hwndSortorder,CB_INSERTSTRING,2,(LONG)(LPSTR)"Width");
SendMessage(hwndSortorder,CB_INSERTSTRING,3,(LONG)(LPSTR)"Proportion (Height/Width)");
SendMessage(hwndSortorder,CB_INSERTSTRING,4,(LONG)(LPSTR)"Weight");
SendMessage(hwndSortorder,CB_INSERTSTRING,5,(LONG)(LPSTR)"Font Family");
hwndSampletext=GetDlgItem(hwnd,IDD_SAMPLETEXT);
SendMessage(hwndSampletext,CB_INSERTSTRING,0,(LONG)(LPSTR)"\"AENOPS abefglmoqsty 801\"");
SendMessage(hwndSampletext,CB_INSERTSTRING,1,(LONG)(LPSTR)"Text Paragraph");
SendMessage(hwndSampletext,CB_INSERTSTRING,2,(LONG)(LPSTR)"Alphabet");
SendMessage(hwndSampletext,CB_INSERTSTRING,3,(LONG)(LPSTR)"\"Sample Text\"");
hwndJustification=GetDlgItem(hwnd,IDD_JUSTIFICATION);
SendMessage(hwndJustification,CB_INSERTSTRING,0,(LONG)(LPSTR)"Justified");
SendMessage(hwndJustification,CB_INSERTSTRING,1,(LONG)(LPSTR)"Left");
SendMessage(hwndJustification,CB_INSERTSTRING,2,(LONG)(LPSTR)"Center");
SendMessage(hwndJustification,CB_INSERTSTRING,3,(LONG)(LPSTR)"Right");
hwndSize=GetDlgItem(hwnd,IDD_SIZE);
hwndDesc=GetDlgItem(hwnd,IDD_SHOWDESCRIPTION);
// fall through to set defaults...
case IDD_DEFAULTS:
SendMessage(hwndSortorder,CB_SETCURSEL,0,0L);
SendMessage(hwndSampletext,CB_SETCURSEL,0,0L);
SendMessage(hwndJustification,CB_SETCURSEL,1,0L);
CheckRadioButton(hwnd,IDD_PITCHBOTH,IDD_PITCHVARIABLE,IDD_PITCHBOTH);
CheckRadioButton(hwnd,IDD_DEVICEPRINTER,IDD_DEVICESCREEN,IDD_DEVICEPRINTER);
CheckDlgButton(hwnd,IDD_SYNTHESIS,1);
CheckDlgButton(hwnd,IDD_TRUETYPEONLY,0);
CheckDlgButton(hwnd,IDD_NOVELTY,1);
CheckDlgButton(hwnd,IDD_MODERN,1);
CheckDlgButton(hwnd,IDD_ROMAN,1);
CheckDlgButton(hwnd,IDD_SANSSERIF,1);
CheckDlgButton(hwnd,IDD_SCRIPT,1);
CheckDlgButton(hwnd,IDD_OTHERFONTS,1);
CheckDlgButton(hwnd,IDD_REGULAR,1);
CheckDlgButton(hwnd,IDD_ITALIC,1);
CheckDlgButton(hwnd,IDD_BOLD,1);
CheckDlgButton(hwnd,IDD_BOLDITALIC,1);
CheckDlgButton(hwnd,IDD_LAUNCHWRITE,1);
SendMessage(hwndSize,WM_SETTEXT,0,(LONG)(LPSTR)"18");
default_font="Arial";
default_ffid=FF_SWISS;
default_pointsize=16;
default_just=JUST_LEFT;
default_bolditalic=0;
{ // adjust points to logical units
HDC hdc=CreateIC("DISPLAY",NULL,NULL,NULL);
if(hdc==NULL)OldLfHeight=10;
else{
OldLfHeight=MulDiv(-(default_pointsize/2),
GetDeviceCaps(hdc,LOGPIXELSY),72);
DeleteDC(hdc);
}
}
show_default_text_settings(hwndDesc);
SetFocus(hwndSortorder);
return 1;
case IDOK: // make the file
for(;;){
SetCapture(hwnd);
if(hHourGlass!=NULL)hSaveCursor=SetCursor(hHourGlass);
switch(SendMessage(hwndSortorder,CB_GETCURSEL,0,0L)){
default: